package cn.camel.algorithm.tree.disjoint_set;

/**
 * @author: Camel
 * @description: 测试
 * @date: 2025/10/19 18:19
 */
public class Test {
    public static void main(String[] args) {
        DisjointSet ds = new DisjointSet(10);

        // 初始状态：10个独立集合
        System.out.println("初始连通分量: " + ds.getCount()); // 10

        // 执行合并操作
        ds.union(1, 2);
        ds.union(2, 3);
        ds.union(4, 5);
        ds.union(5, 6);
        ds.union(3, 4);

        System.out.println(ds.getParent()[1] +"   "+ ds.getParent()[6]);
        // 检查连通性
        System.out.println("1和6是否连通: " + ds.isConnected(1, 6)); // true
        System.out.println("1和7是否连通: " + ds.isConnected(1, 7)); // false
        System.out.println("当前连通分量: " + ds.getCount()); // 5
    }
}
